﻿#region itdc

/************************************************************************
*Copyright(C) 2015 by qsgy
 *All rights reserved. 
 *FileName:     $safeitemname$
 *Author:       oyh
 *Version:      
 *UnityVersion：
 *Date:   $time$      
 *Description:    
 *History: 
************************************************************************/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 计数激活器。
/// 当value达到临界值，激活或者关闭指定对象
/// value由sender通知
/// </summary>
public class CountActive : Activator,Receiver<short>
{
    
    [Tooltip("默认的触发临界值")]
    public short tagertValue=3;
    [Tooltip("当前值"),ReadOnly]
    public short value = 0;
    [Tooltip("激活，关闭模式.true为激活模型")]
    public bool actType = true;


    public short Value
    {
        get
        {
            return value;
        }

        set
        {
            this.value = value;
            if (value>=tagertValue)
            {
                SetAct(actType);
            }
        }
    }

    public void Reveive(TMessage<short> t)
    {
        //fixme
        Value += t.Message;
    }

   
}
